<template>
  <div v-loading="loading" class="login-page"></div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import db from '../utils/localstorage.js'
import { useAccountStore } from '../stores/account.js'
const loading = ref(true)
const route = useRoute()
const router = useRouter()
const accountStore = useAccountStore()

onMounted(async () => {
  if (route.query.token) {
    db.save('ACCESS_TOKEN', route.query.token)
    const user = await accountStore.getUser()
    if (user) {
      router.replace('/airdrop')
    } else {
      location.href = '/airdrop'
    }
  } else {
    location.href = '/airdrop'
  }
})
</script>

<style lang="less" scoped>
.login-page {
  flex: 1;
  background: #000;
  background-size: 100%;
  position: relative;
}
</style>
